package com.jb.repair.util;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Random;

/**
 * Created by SLF on 2015/11/6.
 */
public class TimeUtil {
    public static String generateFilenameString() {
        SimpleDateFormat df = new SimpleDateFormat("yyyyMMddHHmmss");
        return df.format(new Date()) + "_"
                + new Random().nextInt(1000);
    }

    /**
     * 获取系统当前时间，如2015-01-01 12:20
     * @return
     */
    public static String getSystemTime(){
        Long miles = System.currentTimeMillis();
        SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm");
        Date date = new Date(miles);
        return df.format(date);
    }

    public static String getSystemTime(SimpleDateFormat sdf){
        Long miles = System.currentTimeMillis();
        Date date = new Date(miles);
        return sdf.format(date);
    }

}
